﻿using System.ComponentModel;

namespace CSharpPro._1009;

public class Demo1
{
    
    //练习
    public void TestPrint()
    {
        int num = 10;
        for (int i = 0; i < 10 ; i++)
        {
            if (i % 2 != 0)
            {
                Console.Write(i+"\t");
            }
        }
    }
    
    //作业1输出1000以内的水仙花数
    public void TestPrint1()
    {
        for (int num = 100; num < 1000; num++)
        {
            int ge = num  % 10;
            int shi = (num / 10) % 10;
            int bai = num / 100;
            int sum = ge * ge * ge + shi * shi * shi + bai * bai * bai;
            if(num == sum)
            {
                Console.Write(num + "\t");
            }
        }
    }
    
    //作业2输出100以内所有的质数
    public void TestPrint2()
    {
        for (int num = 2; num <= 100; num++)
        {
            bool isPrime = true;
            for (int i = 2; i <= Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    isPrime = false;
                    break;
                }
            }
            if (isPrime)
            {
                Console.Write(num+" ");
            }
        }
        Console.WriteLine();
    }
    
    
}